﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DTO;
using Data;
namespace DAO
{
    public class Quay_DAO
    {
        public static List<Quay_DTO> SelectAll()
        {
            List<DTO.Quay_DTO> result = new List<DTO.Quay_DTO>();
            DataTable dt = Data.SQLAccess.ExecuteQuery("select *from QUAY");
            DTO.Quay_DTO quay;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                quay = new DTO.Quay_DTO();
                quay._Ma_Quay = int.Parse(dt.Rows[i]["MA_QUAY"].ToString());
                quay._Ten_Quay = dt.Rows[i]["TEN_QUAY"].ToString();
                quay._Ma_NV = int.Parse(dt.Rows[i]["MA_NV"].ToString());
                quay._Vi_Tri = dt.Rows[i]["VI_TRI"].ToString();
                quay._Ghi_Chu = dt.Rows[i]["GHI_CHU"].ToString();
                result.Add(quay);
            }
            return result;
        }
        public static string Insert(DTO.Quay_DTO quay)
        {
            try
            {
                string str_sql = "insert into QUAY values("
                + quay._Ma_Quay + ",N'"
                + quay._Ten_Quay + "',"
                + quay._Ma_NV + ",N'"
                + quay._Vi_Tri + "',N'"
                + quay._Ghi_Chu + "'"
                + ")";
                DataTable dt = Data.SQLAccess.ExecuteQuery(str_sql);
                return "true";
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
        public static string Delete(NhaCungCap_DTO nha_cung_cap)
        {
            try
            {
                return "true";
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
    }
}
